#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 210, M = 8e4 + 10;
int arr[N];
int f[M];
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		memset(arr, 0, sizeof(arr));
		memset(f, 0, sizeof(f));
		for (int i = 1; i <= n; i++) {
			cin >> arr[i];	
		}
		sort(arr + 1, arr + n + 1);
		for (int i = 1; i < n; i++) {
			for (int j = m - 1; j >= arr[i]; j--) {
				f[j] = max(f[j], f[j - arr[i]] + arr[i]);
			}
		}
		cout << f[m - 1] + arr[n] << endl;
	}
	return 0;
}